<?php
$loader->requireOnce('includes/Insurance/InsuranceEngine.class.php');
class DisccountManager {
    protected $discountObjectList = array();
    protected $objStorage;

    function __construct(&$objStorage) {
    	$this->objStorage  =   $objStorage;
    	self::createDiscoutableObjectList();
    }

    private function createDiscoutableObjectList() {
        $insInfo    =   $this->objStorage->getInsuranceInfo();
        if ($insInfo->getInsuranceGroup() !== false) {
            $insCalculator  =   InsuranceEngine::createInsuranceCalculator($insInfo, $this->objStorage->getTotalOriginalAmount());
            $this->discountObjectList[] =   $insCalculator;
        }
    }

    public function performDiscount() {
        foreach ($this->discountObjectList as $discounter) {
        	$discounter->discount($this->objStorage);
        }
    }
}
?>